package com.ncu.cloundeoffice.controller;


import com.ncu.cloundeoffice.pojo.ResponseResult;
import com.ncu.cloundeoffice.pojo.TSalary;
import com.ncu.cloundeoffice.service.TSalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/salary/sob")
public class TSalaryController {

    @Autowired
    private TSalaryService tSalaryService;

    /**
     * 查询所有的工资账套
     * @return
     */
    @GetMapping("/")
    public List<TSalary> getAllTSalary(){
        return tSalaryService.getAllTSalary();
    }

    /**
     * 删除工资账套
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public ResponseResult deleteSalaryById(@PathVariable("id") int id){
        return tSalaryService.deleteSalaryById(id);
    }

    /**
     * 添加工资账套
     * @param tSalary
     * @return
     */
    @PostMapping("/")
    public ResponseResult addSalary(@RequestBody TSalary tSalary){
        tSalary.setCreateDate(new Date());
        return tSalaryService.addSalary(tSalary);
    }

    /**
     * 更新工资账套
     * @param tSalary
     * @return
     */
    @PutMapping("/")
    public ResponseResult updateSalary(@RequestBody TSalary tSalary){
        return tSalaryService.updateSalary(tSalary);
    }
}
